package HLLib.ui;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLObject;
import HLLib.base.HLGraphics;
import HLLib.base.HLImage;
import HLLib.base.HLRectangle;
import HLLib.io.HLFile;

public class HLUIControlImageFill extends HLUIControl {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_UI, HLClassManager_H.LIB_CLASS_UI_UIControlImageFill);
    }

    public int GetInt(int index) {
        switch (index) {
        case 1: {
            return imageTrans;
        }
        }
        return super.GetInt(index);
    }

    public void SetInt(int index, int value) {
        switch (index) {
        case 1: {
            imageTrans = (byte) value;
            return;
        }
        }
        super.SetInt(index, value);
    }

    public boolean GetBoolean(int index) {
        return super.GetBoolean(index);
    }

    public void SetBoolean(int index, boolean value) {
        super.SetBoolean(index, value);
    }

    public HLObject GetObject(int index) {
        switch (index) {
        case 0: {
            return image;
        }
        }
        return super.GetObject(index);
    }

    public void SetObject(int index, HLObject value) {
        switch (index) {
        case 0: {
            image = (HLImage) value;
            return;
        }
        }
        super.SetObject(index, value);
    }

    public byte imageTrans;

    public HLImage image;

    public HLUIControlImageFill() {
    }

    HLUIControlImageFill(HLUIFrame ownerFrame) {
        super(ownerFrame);
    }

    void Load(HLFile file) {
        super.Load(file);

        byte packageIndex = file.ReadInt8();
        short imageIndex = file.ReadInt16();

        imageTrans = file.ReadInt8();

        image = ownerFrame.owner.ownerUISeedManager.imageManager.GetImageEX(packageIndex, imageIndex, false);
    }

    void Render(HLGraphics g, int rectX, int rectY, int rectWidth, int rectHeight, int color) {
        HLRectangle area = GetArea(rectX, rectY, rectWidth, rectHeight);
        g.DrawImageFillRectEX(image, area.x, area.y, area.width, area.height, imageTrans, false, false, color, 0, 0, 0);
    }
    

    void CopyFrom(HLUIControl uiControl) {
        super.CopyFrom(uiControl);

        HLUIControlImageFill uiControlByType = (HLUIControlImageFill) uiControl;

        imageTrans = uiControlByType.imageTrans;

        image = uiControlByType.image;
    }

    HLUIControl Clone(HLUIFrame ownerFrame) {
        HLUIControlImageFill uiControl = new HLUIControlImageFill();
        uiControl.ownerFrame = ownerFrame;
        uiControl.CopyFrom(this);
        return uiControl;
    }
}
